<?php

namespace app\http\middleware;

/**
 * Class InAppCheck
 * @package app\http\middleware
 * 访问环境检查，是否是微信或支付宝等
 */

class InAppCheck
{
    public function handle($request, \Closure $next)
    {
        if (preg_match('~micromessenger~i',$request->header('user-agent'))){
            $request->InApp = 'WeChat';
        }
        else if (preg_match('~alipay~i',$request->header('user-agent'))){
            $request->InApp = 'Alipay';
        }
        else
        {
            $request->InApp ='pc';
        }

        return $next($request);
    }
}
